#!/usr/bin/env python
# -*- coding: utf-8 -*-

from django.db import models
from django.core.validators import MaxValueValidator
import os
import sys
import django

sys.path.append(r"web")
sys.path.append(r"algorithm")
sys.path.append(r"cta")

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'adam3.settings')
django.setup()


class CommodityFutureDateCorrelation(models.Model):
    """
    商品期货相关系数
    """

    # 主键
    id = models.AutoField(primary_key=True)

    # 代码
    code = models.CharField(max_length=32, db_index=True, null=True, blank=True)

    # 对照品种的代码
    with_code = models.CharField(max_length=32, db_index=True, null=True, blank=True)

    # 日期
    date_ = models.DateField(null=True, db_index=True, blank=True)

    # 表示几日之内的相关系数
    date_number = models.IntegerField(validators=[MaxValueValidator(2147483647)], null=True,
                                    blank=True)

    # 相关系数
    correlation = models.DecimalField(max_digits=32, decimal_places=16, null=True, blank=True)

    class Meta:
        managed = True
        db_table = 'C_F_DATE_CORRELATION'
        verbose_name = '商品期货各个品种之间的相关性'
        verbose_name_plural = verbose_name